package com.talent.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * May The Force Be With You
 * <p>
 * Created by zhumenglong on 2017/8/30.
 */
@Controller
@RequestMapping("/auth")
public class LoginController {

    /**
     * 登录
     * @param session
     * 			HttpSession
     * @param username
     * 			用户名
     * @param password
     * 			密码
     * @return
     */
    @PostMapping("/login")
    public String login(HttpSession session, String username, String password) throws Exception{
        //在Session里保存信息
        session.setAttribute("username", username);
        return "hello";
    }

    /**
     * 退出系统
     * @param session
     * 			Session
     * @return
     * @throws Exception
     */
    @RequestMapping("/logout")
    public String logout(HttpSession session) throws Exception{
        //清除Session
        session.invalidate();

        return "redirect:/";
    }
}
